﻿
          function loadDocument(fileName) 
{
    var xmlDoc = window.ActiveXObject ? new ActiveXObject("MSXML2.DOMDocument.3.0") :
                                        document.implementation.createDocument("","",null);
    xmlDoc.async = false;
    xmlDoc.load(fileName);
    return xmlDoc;
}

function getTransformedHTML(xmlDoc, xslDoc) {
     var html = "";
     if (window.XSLTProcessor) 
     {
          var xsltProc = new XSLTProcessor();
          xsltProc.importStylesheet(xslDoc);
          var fragment = xsltProc.transformToFragment(xmlDoc, document);
          html = new XMLSerializer().serializeToString(fragment);
     } 
     else if (window.ActiveXObject) 
     {
          html = xmlDoc.transformNode(xslDoc);
     }
     return html;
}

function Transform()
{
   var xmlDoc = loadDocument("runners.xml");
   var xslDoc = loadDocument("runners.xsl");      
   document.getElementById("example").innerHTML = getTransformedHTML(xmlDoc, xslDoc);
}

       
